<!--
 * @Description: 
 * @Author: mmzhang
 * @Date: 2023-01-13 10:11:11
 * @LastEditTime: 2023-02-07 16:06:26
-->
<template>
  <div class="content">
    <dt-search ref="search">
      <Button type="primary" v-if="unlocking('0207010401')" @click='onExport'>导出</Button>
    </dt-search>
    
    <dt-grid ref="table" page :onFetch='onFetch' />
	</div>
</template>

<script>
  import Column from './opt/Column.js'
  import SearchOpt from './opt/SearchOpt.js'
  import contractMgr from '@/biz/buildingManagement/contract.js'
  import buildMgr from '@/biz/building'
  import store from '@/store'
  import caseMgr from "@/biz/crimeSceneList";
  import { buildPage } from '@/router/buildPage.js'

  export default {
    data() {
      return {
        search: {}
      }
    },
    mounted() {
      this.$refs.search.init(this.$refs.table, new SearchOpt())
      this.$refs.table.init(this, new Column())
      this.$refs.table.fetch()
    },
    methods: {
      onFetch(data) {
        this.search = data
        return contractMgr.collectList(data)
      },
      onExport() {
        return contractMgr.collectExport(this.search)
      },
      linkDetailFun(housesId){
        let params = {
          housesId: housesId
        }
        caseMgr.buildinghousesList(params).then((res) => {
          let item = { ...res.list[0] }
          // 更新案场
          buildMgr.updateBuildInfo(item)
          this.$tool.setStorage({ caseBuildingId: JSON.stringify(item.housesId) })
          store.dispatch('setRouterList', buildPage)

          this.$router.push({
            name: 'buildingConfigure',
            params:{
              fromCustomer:'contract'
            }
          }) // 案场配置 合同管理
        })
      }
    },
  }
</script>

<style lang="scss" scoped>
  .content {
    padding: 20px;
  }
</style>
